package com.rd.student.jiaji.class3.sunguowei.Questions;

import java.util.concurrent.atomic.AtomicInteger;

public class Test22 implements Runnable{
    int num =0;
    static AtomicInteger number = new AtomicInteger(0);


    @Override
    public void run(){
        int num1=0;
        for (int i=0;i<10;i++){
            num++;
            num1+= num;
            number.getAndAdd(num);
        }
        System.out.println(num1);

    }

    public static void main(String[] args) throws InterruptedException {
        Test22 text = new Test22();
        Thread t1=new Thread(text);
        Thread t2=new Thread(text);
        Thread t3=new Thread(text);
        Thread t4=new Thread(text);
        Thread t5=new Thread(text);
        Thread t6=new Thread(text);
        Thread t7=new Thread(text);
        Thread t8=new Thread(text);
        Thread t9=new Thread(text);
        Thread t10=new Thread(text);
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();
        t3.join();
        t4.start();
        t4.join();
        t5.start();
        t5.join();
        t6.start();
        t6.join();
        t7.start();
        t7.join();
        t8.start();
        t8.join();
        t9.start();
        t9.join();
        t10.start();
        t10.join();
//        for (int i = 0; i < 10; i++) {
//            new Thread(text).start();
//        }
        System.out.println(number);

    }
}
